<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('学生项目管理')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="data-form">
                <div class="select-list">
                    <input id="trainingModuleType" name="trainingModuleType" type="hidden" th:value="*{moduleId}"/>
                    <ul>
                        <li>
                            <label style="width: 80px">科目：</label>
                            <select name="projectType" th:with="type=${@dict.getType('business_project_type')}" class="form-control">
                                <option value="">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 80px">测评类型：</label>
                            <select name="evaluateModuleType" th:with="type=${@dict.getType('business_project_module')}" class="form-control">
                                <option value="">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 80px">测评题目：</label>
                            <input type="text" name="evaluateQuestion"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                           <!-- <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    // 字典
    var projectType = [[${@dict.getType('business_project_type')}]];
    var evaluateModuleType = [[${@dict.getType('business_project_module')}]];
    var prefix = ctx + "education/question";
    var addprefix = ctx + "education/trainingProgramReporttype";

    $(function () {
        var options = {
            url: prefix + "/listwithoutreporttype",
            rememberSelected: true,
            queryParams: queryParams,
            columns: [
                {
                    field: 'state',
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false

                },
                {
                    field: 'projectType',
                    title: '科目',
                    align: "center",
                    formatter: function (value, row, index) {
                        if ($.common.isNotEmpty(value)) {
                            return $.table.selectDictLabel(projectType, value);
                        } else {
                            return null;
                        }
                    }
                },
                {
                    field: 'projectModule',
                    title: '测评类型',
                    align: "center",
                    formatter: function (value, row, index) {
                        if ($.common.isNotEmpty(value)) {
                            return $.table.selectDictLabel(evaluateModuleType, value);
                        } else {
                            return null;
                        }
                    }
                },
                {
                    field: 'question',
                    title: '测评题目',
                    align: "center"
                }]
        };
        $.table.init(options);
    });

    function editProjectInformation(questionId) {
        var url = ctx + "education/trainingProgram/edit/" + questionId;
        $.modal.openTab("项目管理", url);
    }

    function queryParams(params) {
        var trainingModuleType = $("#trainingModuleType").val();
        var search = $.table.queryParams(params);
        search.reportType = trainingModuleType;
        return search;
    }


    function submitHandler() {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var trainingModuleType = $("#trainingModuleType").val();
        var arrays = $.table.selectColumns("id");
        var data ={
            trainingModuleType: trainingModuleType,
            questionIds: arrays
        }
        $.ajax({
            url: addprefix+"/add",
            type: "post",
            contentType:"application/json",
            data:JSON.stringify(data),
            success: function(result) {
                if (result.code == 0) {
                    $.modal.close();
                    parent.refresh();
                } else {
                    $.modal.alertError(result.msg);
                }
            }
        })
    }

</script>
</body>

</html>